package com.ogms.dge.container.modules.data.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ogms.dge.container.common.utils.PageUtils;
import com.ogms.dge.container.common.utils.Query;
import com.ogms.dge.container.modules.data.converter.RecordConverter;
import com.ogms.dge.container.modules.data.dao.RecordDao;
import com.ogms.dge.container.modules.data.entity.RecordEntity;
import com.ogms.dge.container.modules.data.service.RecordService;
import com.ogms.dge.container.modules.data.service.ServiceService;
import com.ogms.dge.container.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service("recordService")
public class RecordServiceImpl extends ServiceImpl<RecordDao, RecordEntity> implements RecordService {

    @Resource
    private RecordConverter recordConverter;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private ServiceService serviceService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<RecordEntity> page = this.page(
                new Query<RecordEntity>().getPage(params),
                new QueryWrapper<RecordEntity>()
        );
        PageUtils pageUtils = new PageUtils(page);
        pageUtils.setList(recordConverter.poList2VoList(page.getRecords(), sysUserService, serviceService));

        return pageUtils;
    }

}